package problemSpace;

import java.util.ArrayList;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

@XmlRootElement(name = "Station")
public class Station {
	@XmlElement(name = "StationCode")
	public String stationCode;
	@XmlElement(name = "LoadingMinutes")
	public int loadingMinutes;
	@XmlTransient
	public ArrayList<timeInterval> occupied;

	public Station() {
		this.occupied = new ArrayList<timeInterval>();
	}
	
	public Station(Station trein){
		this.stationCode = trein.stationCode;
		this.loadingMinutes = trein.loadingMinutes;
		this.occupied = new ArrayList<timeInterval>();
		for( timeInterval ti : trein.occupied) this.occupied.add(new timeInterval(ti));
	}

	public Station(String stationCode, int loadingMinutes) {
		this.stationCode = stationCode;
		this.loadingMinutes = loadingMinutes;
		this.occupied = new ArrayList<timeInterval>();
	}

	public int removeTimeInterval(String orderCode) {
		int numberDeleted = 0;
		for(int i = occupied.size()-1; i>=0; i--){
			if(occupied.get(i).orderCode.equals(orderCode)){
				occupied.remove(i);
				numberDeleted++;
			}
		}
		return numberDeleted;
	}

}
